home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / objcissu.lha / persistence < prev    next >
Text File  |  1993-03-01  |  19KB  |  431 lines

  1. Date: Tue, 15 Sep 92 15:22:38 -0700
  2. From: Dennis Glatting <seattle-ni-srvr!dglattin@trirex.com>
  3. To: uunet!lehigh.edu!gdb0@uunet.uu.net (GLENN BLANK)
  4. Subject: Re: Automatic input/output, persistence
  5. Cc: gnu-objc@prep.ai.mit.edu
  6. Reply-To: dennis_glatting@trirex.com
  7.  
  8. > A key difference between the NeXT and StepStone
  9. > foundation class libraries is the latter supports a much
  10. > more convenient scheme for storing objects to and
  11. > reading them back from files. The NeXT version, as I
  12. > understand it (I don't have a NeXT; I have a Sun running
  13. > Stepstone's version), only supports what I would call
  14. > "semi-automatic" input/output--that is, the
  15. > implementor of each subclass must implement methods to
  16. > archive objects of this subclass.  The Stepstone library
  17. > does not require any new implementation at all.  If your
  18. > object is a subclass of Stepstone's Object, it
  19. > automatically inherits Object's hooks automatic
  20. > input/output--providing you explicitly link in the
  21. > relevant code.  
  22. >
  23.  
  24. Doesn't this break the concept of encapsulation?  Shouldn't the object itself be responsible for what it contains and what is relevant rather than an outside entity?  How does one automatically store a void*? 
  25.  
  26. -dpg
  27.  
  28. Date: Thu, 17 Sep 92 08:58:43 CDT
  29. From: shirley@gothamcity.jsc.nasa.gov (Bill Shirley [CSC])
  30. To: gnu-objc@prep.ai.mit.edu
  31. Subject: Re: Automatic input/output, persistence
  32.  
  33.  
  34.  I tried to send this easlier, but it bounced at the source.  I hope
  35. I'm not repeating something you already got:
  36.  
  37. ]] From shirley Fri Sep 11 13:47:30 1992
  38.  
  39.  
  40. |> From: gdb0@lehigh.edu (GLENN BLANK)
  41.  
  42. I don't understand most of this, I may need more explaining to.
  43.  
  44. |> A key difference between the NeXT and StepStone foundation class
  45. |> libraries is the latter supports a much more convenient scheme
  46. |> for storing objects to and reading them back from files.
  47.  
  48. |> The NeXT version, as I understand it (I don't have a NeXT; I have
  49. |> a Sun running Stepstone's version), only supports what I would call
  50. |> "semi-automatic" input/output--that is, the implementor of each subclass
  51. |> must implement methods to archive objects of this subclass.  The
  52.  
  53. On NeXTs, the implementor must archive the instance variables
  54. (that he wants archived)
  55.  
  56. |> Stepstone library does not require any new implementation at all.  If
  57. |> your object is a subclass of Stepstone's Object, it automatically
  58. |> inherits Object's hooks automatic input/output--providing you
  59. |> explicitly link in the relevant code.  
  60.  
  61. What does this *mean*?
  62.    "automatically... providing..."?
  63.  
  64. What relevant code?
  65.  
  66. |> Semi-automatic input/output is about all C++ libraries can do:
  67. |> since C++ does not support metaclass information at run-time.
  68. |> Automatic input/output is one of the very nice features of Smalltalk,
  69. |> which Objective-C can imitate, because it does support metaclasses,
  70. |> and so can know how to allocate instances of some class when it
  71. |> reads one from a file.
  72.  
  73. What happens if I have modified the Class in the interim?
  74. (This is a problem that all implementations have to deal with,
  75.  I am interested in how Stepstone does (or you (pl) would) in this case)
  76.  
  77. |> Needless to say, automatic input/output
  78. |> can save a lot of work, especially in continually evolving
  79. |> applications like mine.
  80.  
  81. By continually evolving, do you mean class implementations are changing?
  82.  
  83. |> I'd sure like to see support for it in the 
  84. |> GNU version, rather than settle for the NeXT interface.
  85.  
  86. I'll wait to vote until I understand it :-)
  87.  
  88. |> May I point out that automatic input/output also opens the door
  89. |> for object persistence.  This need not imply a full blown OODB,
  90. |> with query capabilities, etc.
  91.  
  92. What does "object persistence" mean?  I'll have to plead ignorant
  93. on much DB theory.
  94.  
  95. |> The StepStone implementation stores 
  96. |> one whole object per file
  97.  
  98. That does sound like a limitation
  99.  
  100. |>                 --the object can be arbitrarily complex,
  101. |> e.g., the filer will handle vanilla C instance variables, 
  102. |> chase object ids, yet avoid duplicating objects to which there
  103. |> is more than one pointer.  A more flexible design might allow one 
  104. |> to store/access many objects per file.  
  105.  
  106. like NIB files.
  107.  
  108. What if an object creates a large amount of instance variables that it
  109. doesn't NEED to archive.  (It could create this extra data for algorithmic
  110. efficiency, for example).
  111.  
  112. (A string object may keep the number of characters,
  113. the size of the storage it allocated, the number of words, whether the
  114. characters are all numeric, alphabetic,..., but you would only NEED to
  115. archive the actual sequence of characters, the other information can
  116. be computed after the string is unarchived.)
  117.  
  118.  -Bill S.
  119.  
  120. Date: Thu, 17 Sep 1992 11:12:05 EDT
  121. From: gdb0@lehigh.edu (GLENN BLANK)
  122. Subject: Re: Automatic input/output, persistence
  123. To: shirley@gothamcity.jsc.nasa.gov (Bill Shirley [CSC])
  124. Cc: gnu-objc@prep.ai.mit.edu
  125.  
  126. > I tried to send this easlier, but it bounced at the source.  I hope
  127. >I'm not repeating something you already got:
  128.  
  129. No repetition.
  130.  
  131. >]] From shirley Fri Sep 11 13:47:30 1992
  132. >
  133. >|> From: gdb0@lehigh.edu (GLENN BLANK)
  134. >
  135. I don't understand most of this, I may need more explaining to.
  136. >
  137. >|> A key difference between the NeXT and StepStone foundation class
  138. >|> libraries is the latter supports a much more convenient scheme
  139. >|> for storing objects to and reading them back from files.
  140. >
  141. >|> The NeXT version, as I understand it (I don't have a NeXT; I have
  142. >|> a Sun running Stepstone's version), only supports what I would call
  143. >|> "semi-automatic" input/output--that is, the implementor of each subclass
  144. >|> must implement methods to archive objects of this subclass.  The
  145. >
  146. >On NeXTs, the implementor must archive the instance variables
  147. >(that he wants archived)
  148.  
  149. In other words, on NeXTs, the implementor needs to explicitly
  150. implement methods for each class of object that he wants to archive.
  151.  
  152. >
  153. >|> Stepstone library does not require any new implementation at all.  If
  154. >|> your object is a subclass of Stepstone's Object, it automatically
  155. >|> inherits Object's hooks automatic input/output--providing you
  156. >|> explicitly link in the relevant code.
  157. >
  158. >What does this *mean*?
  159. >   "automatically... providing..."?
  160. >What relevant code?
  161. >
  162.  
  163. Using Stepstone's library, you never have to write, or modify, code
  164. for storing objects to and reading them from files.  Providing you
  165. force the compiler to explicitly link in the some code, e.g., by 
  166. having the following statements in your main():
  167.     [AsciiFiler self];  //Force linking of this code into your program
  168. You need to force linking of any classes (and their methods) that
  169. aren't  explicitly mentioned in your code, but will be invoked when
  170. you invoke a method which in turn invokes a method of AsciiFiler.
  171. E.g., [myObject storeOn:"filename"] invokes the storeOn method, which
  172. MyClass inherits from Object.  Object's storeOn method in turn invokes
  173. a method in AsciiFiler...  Other than this slightly annoying step
  174. (which a smarter compiler should be able to figure out for itself, IMHO)
  175. storeOn:/readFrom: are automatic, just as in Smalltalk.
  176.  
  177. >|> Semi-automatic input/output is about all C++ libraries can do:
  178. >|> since C++ does not support metaclass information at run-time.
  179. >|> Automatic input/output is one of the very nice features of Smalltalk,
  180. >|> which Objective-C can imitate, because it does support metaclasses,
  181. >|> and so can know how to allocate instances of some class when it
  182. >|> reads one from a file.
  183. >
  184. >What happens if I have modified the Class in the interim?
  185. >(This is a problem that all implementations have to deal with,
  186. > I am interested in how Stepstone does (or you (pl) would) in this case)
  187. >
  188.  
  189. Good point.  Stepstone doesn't handle this particularly well--if
  190. your program tries to readFrom: an object whose structure does not
  191. match the structure compiled into your program (you made a change
  192. since your last storeOn:), your program crashes, dumping a backwards
  193. trace indiciting that readFrom: fails at some point.  (Earlier, your
  194. program failed without even a backwards trace!)  An improvement would
  195. involve version control.  Each time you change the structure of a
  196. class, it gets a new version number, and readFrom: first checks for
  197. a corresponding version number.  Versioning might also support
  198. automatic conversion of an old version of an object in a file to the
  199. new version format.
  200.  
  201. >|> Needless to say, automatic input/output
  202. >|> can save a lot of work, especially in continually evolving
  203. >|> applications like mine.
  204. >
  205. >By continually evolving, do you mean class implementations are changing?
  206.  
  207. Yes.  I add new instance variables, but don't need to add new I/O code.
  208.  
  209. >|> I'd sure like to see support for it in the
  210. >|> GNU version, rather than settle for the NeXT interface.
  211. >
  212. >I'll wait to vote until I understand it :-)
  213.  
  214. What do you say now?  Would you still rather have to write all your
  215. own input/output code--a source of tedious bugs?
  216.  
  217. >|> May I point out that automatic input/output also opens the door
  218. >|> for object persistence.  This need not imply a full blown OODB,
  219. >|> with query capabilities, etc.
  220. >
  221. >What does "object persistence" mean?  I'll have to plead ignorant
  222. >on much DB theory.
  223.  
  224. Persistence means that an object continues to exist after the program
  225. that created it terminates (usually in a file somewhere).  Temporary
  226. objects are deallocated when a block or program terminates.  Persistent
  227. objects can be accessed by subsequent programs, and thus provide a
  228. basis for OODBs.  OODBs raise a host of other issues beyond simple
  229. persistence, such as efficient access, query languages, etc.  But
  230. simple persistence is a good place to start.
  231.  
  232. >|> The StepStone implementation stores
  233. >|> one whole object per file
  234. >
  235. >That does sound like a limitation
  236.  
  237. Yes--especially for OODBs, or even if you just want to append elements
  238. to a collection object.
  239.  
  240. >|>                 --the object can be arbitrarily complex,
  241. >|> e.g., the filer will handle vanilla C instance variables,
  242. >|> chase object ids, yet avoid duplicating objects to which there
  243. >|> is more than one pointer.  A more flexible design might allow one
  244. >|> to store/access many objects per file.
  245. >
  246. >like NIB files.
  247.  
  248. Sorry, what's a NIB file?
  249. >
  250. >What if an object creates a large amount of instance variables that it
  251. >doesn't NEED to archive.  (It could create this extra data for algorithmic
  252. >efficiency, for example).
  253.  
  254. >(A string object may keep the number of characters,
  255. >the size of the storage it allocated, the number of words, whether the
  256. >characters are all numeric, alphabetic,..., but you would only NEED to
  257. >archive the actual sequence of characters, the other information can
  258. >be computed after the string is unarchived.)
  259. >
  260. Good point--I believe this may be another shortcoming of Stepstone's 
  261. algorithm.  Automaticity always involves tradeoffs--how much control
  262. do we want to give the programmer?  Keeping it simple may involve
  263. extra storage, but it seems to me that if you're storing this data
  264. in memory, you shouldn't worry too much about storing it redundantly
  265. in a file.  At least it saves you the trouble of recomputing these data.
  266.  
  267. > -Bill S.
  268. >
  269.  
  270. Glenn B.
  271.  
  272. Date: Thu, 17 Sep 1992 12:26:02 EDT
  273. From: gdb0@lehigh.edu (GLENN BLANK)
  274. Subject: Re: read/write  - NIB
  275. To: shirley@gothamcity.jsc.nasa.gov (Bill Shirley [CSC])
  276. Cc: gnu-objc@prep.ai.mit.edu
  277.  
  278. >|> Sorry, what's a NIB file?
  279. >
  280. >whoops, sorry, I might as well share this with all just for knowledge's
  281. >sake.
  282. >
  283. >NeXT's Interface Builder (which some tout and others scorn)
  284. >creates NIB files, which are loaded in by the Application
  285. >Object (usually) before an [App run] message is sent.
  286. >
  287. >It is basically an archive of all the instanciated objects that
  288. >were created in the Interface Builder.  Thus is contains "more
  289. >than one object" which the previous discussion was about.
  290. >
  291. >Multiple NIB files are often used for parts of the program that
  292. >may or (usually) may not be brought into play.  Such as a window
  293. >with detailed help features or an "info box".
  294. >
  295. >-Bill
  296.  
  297. For clarity, the Stepstone storeOn:/readFrom: methods can store
  298. multiple objects, so long as they are embedded in one root object.
  299. So, I usually storeOn: an object which is a subclass of a collection
  300. class, which in turn holds a directed graph of other objects.
  301.  
  302. But there's no way to store or access individual objects in a
  303. collection in a file.  You get the whole thing.  Persistent
  304. collections should not necessarily involve retrieving the whole
  305. collection (which may be prohibitive if the collection is large), 
  306. but should support random access to elements or subsets of elements.
  307.  
  308.  
  309. Date: Fri, 18 Sep 92 09:40:37 -0400
  310. From: michael@afs.com
  311. To: gnu-objc@prep.ai.mit.edu
  312. Subject: Re: Automatic input/output, persistence
  313.  
  314. Please explain if I've misinterpreted the discussion, but it seems to me that automatic archiving in all cases cannot determine whether or not an ivar should be written to disk.  I have several objects that have constructs that are built at runtime, but it makes no sense to store them to disk if I want to archive the object because they would have no value when read back in.  Sure, I can read in the obsolete values and write over them, but if the obsolete data is large then I'm wasting a lot of disk space.  I'd rather have my object, and not the root class, decide which ivars should and should not be archived.
  315.  
  316. Thanx,
  317. Michael
  318.  
  319. Michael_Pizolato@afs.com
  320.  
  321. Date: Fri, 18 Sep 92 09:49 PDT
  322. From: michael@stb.info.com (Michael Gersten)
  323. To: ucla-cs!prep.ai.mit.edu!gnu-objc@cs.ucla.edu
  324. Subject: Automatic input/output, persistence
  325.  
  326. Begin forwarded message:
  327.  
  328. Please explain if I've misinterpreted the discussion, but it seems to me that automatic archiving in all cases cannot determine whether or not an ivar should be written to disk.  I have several objects that have constructs that are built at runtime, but it makes no sense to store them to disk if I want to archive the object because they would have no value when read back in.  Sure, I can read in the obsolete values and write over them, but if the obsolete data is large then I'm wasting a lot of disk space.  I'd rather have my object, and not the root class, decide which ivars should and should not be archived.
  329.  
  330. Michael_Pizolato@afs.com
  331. ------
  332.  
  333. That is exactly correct. It is not possible to determine in all cases what needs to be saved. However, it is possible to do it correctly in most cases.
  334.  
  335. The point of having default archiving is that if the default does not work, you can override it the same way you override anything else in the inheritance chain. If you have strictly manual archiving (such as the NeXT), you can forget to put the routines in, or the routines might be out of date compared to the current data structure.
  336.  
  337. Besides, although you *can* write code to output a version number, and on input read the version number and then read the corresponding data, all of the read: or write: routines I've seen just do a standard save or restore of all the instance variables, and nothing else. This is the type of default behavior that can be provided automatically.
  338.  
  339.         Michael
  340. --
  341.         Michael Gersten        michael@stb.info.com
  342. HELLO! I'm a signature virus! Join in the fun and copy me into yours!
  343. ex:.-1,. w $HOME/.signature
  344.  
  345. Date: Sat, 19 Sep 92 19:30:24 -0400
  346. From: Steve Naroff
  347. Subject: Re: Automatic input/output, persistence
  348. To: <Steve_Naroff@next.com>
  349. To: gsk@marble.com
  350. To: dglattin@gnu.ai.mit.edu
  351. Cc: uunet!lehigh.edu!gdb0@uunet.uu.net (GLENN BLANK), gnu-objc@prep.ai.mit.edu
  352.  
  353.  
  354. > Shouldn't the object itself be responsible for what it contains and what is relevant rather than an outside entity? 
  355.  
  356. Absolutely...here are three reasons that come to mind:
  357.  
  358. 1) Control over what is persistent (vs. transient). This feature can dramatically effect the size of the composite object (and associated cost to activate it from disk).
  359. 2) Data that needs to be converted on read/write (e.g. ports, file descriptors...i.e. any data that has different meanings across process boundaries).
  360. 3) Version control for converting old objects to new objects...the object database folks call this "schema evolution" (sounds fancy). NeXTSTEP objects can read old versions of themselves without any problem...we don't force the application to evolve all nib files in concert. This flexibility is very hard to achieve without involving the object.
  361.  
  362. Schemes that do not have these capabilities are usually not very useful for building real applications.
  363.  
  364. snaroff
  365.  
  366. Date: Wed, 24 Feb 93 11:28:45 -0600
  367. From: burchard@geom.umn.edu
  368. To: Kresten Krab Thorup <krab@iesd.auc.dk>
  369. Subject: Re: Help with the runtime
  370. Cc: Bill Dudney <dudney@pencom.com>, rms@gnu.ai.mit.edu, gsk@marble.com,
  371.         lupson@geom.umn.edu
  372.  
  373. Kresten Krab Thorup <krab@iesd.auc.dk> writes:
  374. > the code in typedstreams?.  We also need someone to
  375. > actually code things like typed streams.  This is not
  376. > critical for the core runtime, and could be done later. 
  377.  
  378.  
  379. I'm for putting this off.  The whole issue of transport and  
  380. persistence of objects is currently being overhauled by NeXT in light  
  381. of, first, distributed objects, and second, object databases.  At the  
  382. moment we have two different protocols serving this area  
  383. (-read:/-write: and NXTransport), and when the ODI stuff comes on  
  384. line I'm sure that further revision will be needed.
  385.  
  386. I want to see a unified protocol for transport/persistence of  
  387. objects, with the details of connecting to files/sockets/OODBs/Mach  
  388. ports/etc left to the run time.  Until we have that protocol, I say  
  389. hold off.
  390.  
  391. > (2) The type encoding format needs revision/redesign.
  392.  
  393. > One problem not exactly solved yet, is how to manage
  394. > translations to and from machine independent format,
  395. > and who's resplonsibility it should be to do so -- the
  396. > runtime? the compiler? 
  397.  
  398.  
  399.  
  400. Here is briefly, my current proposal:
  401.  
  402. 1. There should be both a string encoding format, intended as a  
  403. transportable specification; and a binary encoding format (i.e.,  
  404. structure), intended for efficient local use only.
  405.  
  406. 2. The required elements of the string format should express only  
  407. language-level concepts.  Optional size fields may be inserted by  
  408. transport mechanisms to ensure consistent interpretation of basic  
  409. types.  The format should be as compatible with NeXT Obj-C as  
  410. possible.
  411.  
  412. 3. The binary encoding is a private structure which contains compiler  
  413. and system-specific information that will enable library functions to  
  414. perform low-level operations on the corresponding types (e.g.,  
  415. feeding them as arguments to a function). 
  416.  
  417.  
  418. 4. Translation from string to binary format is done by a library  
  419. function __builtin_classify_typedesc() which comes with the compiler  
  420. and so knows what it has to know.  This is very similar to the  
  421. current __builtin_classify_type(); it just works with different  
  422. formats for the information.
  423.  
  424. --------------------------------------------------------------------
  425. Paul Burchard    <burchard@geom.umn.edu>
  426. ``I'm still learning how to count backwards from infinity...''
  427. --------------------------------------------------------------------
  428.  
  429.